package com.lagou.edu.service;

import com.lagou.edu.pojo.User;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 赵虎
 * @date 2020/11/25 11:53
 */
@Service("UserService")
public class UserServiceImpl implements UserService {

    @Override
    public User sayHello(User user) {
        System.out.println("调用成功--->参数:" + user);
        user.setUsername(user.getUsername() + "2");
        return user;
    }

    @Override
    public List<User> getUserList(Integer age) {
        List<User> userList = new ArrayList<>();
        User user = new User();
        user.setUsername("zhangsan");
        user.setAge(18);
        userList.add(user);

        User user1 = new User();
        user1.setUsername("lisi");
        user1.setAge(18);
        userList.add(user1);

        User user2 = new User();
        user2.setUsername("tom");
        user2.setAge(30);
        userList.add(user2);

        return userList.stream().filter(item -> item.getAge() > age).collect(Collectors.toList());
    }
}
